package hbase.HbaseStudy;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.hbase.HBaseConfiguration;
import org.apache.hadoop.hbase.TableName;
import org.apache.hadoop.hbase.client.*;

import java.io.IOException;

public class Hb06_deleteData {
    private static String tableName = "sccc01:t3";
    private static Configuration conf;
    private static Connection HConn;
    private static Admin admin;
    private static Table table;
    private static Delete delete;

    public static void main(String[] args) throws IOException {
        conf = HBaseConfiguration.create();
        HConn = ConnectionFactory.createConnection(conf);
        admin = HConn.getAdmin();
        table = HConn.getTable(TableName.valueOf(tableName));

//        new Delete("行建".getBytes()) 删除某一行数据的所有数据
        delete = new Delete("01".getBytes());
        // 删除指定行建、指定列柱的数据 delete.addFamily("info".getBytes());
        // 删除指定行建、指定列柱、指定列的数据 delete.addColumn("info".getBytes(),"name".getBytes());
        // 删除指定行建、指定列柱、指定列、指定时间戳的数据 delete.addColumn("info".getBytes(),"name".getBytes(),1721209050544L);

        table.delete(delete); // 提交删除对象


        table.close();
        admin.close();
        HConn.close();
    }
}
